<input type="hidden" id="manage_group_status" value="<?php echo $this->session->flashdata('manage_group_status'); ?>" />
<script type="text/javascript">
  $(document).ready(function() {
    $("#group_event_date").datepicker({
      format: 'dd-mm-yyyy'
    });
    var manage_group_status = $.trim($('#manage_group_status').val());
    if (manage_group_status == 1) {
      toastr.success('Group added successfully !');
      return false;
    } else if (manage_group_status == 2) {
      toastr.error('Error occured. Try again !');
      return false;
    } else if (manage_group_status == 3) {
      toastr.success('Group event deleted successfully !');
      return false;
    } else if (manage_group_status == 4) {
      toastr.success('Group updated successfully !');
      return false;
    }
  });
</script>

<div class="page" style="min-height: 500px;">
  <div class="page-container">
    <div class="container">
      <div class="row">
        <div class="span3">
          <h4 class="header">Manage Groups</h4>
          <div class="sidebar">
            <ul class="col-nav span3">
              <li><a href="<?php echo base_url('groups_manage/group/'); ?>"><i class="pull-right icon-th-large"></i>Manage Groups</a></li>
              <li><a href="<?php echo base_url('groups_manage/group_member/'); ?>"><i class="pull-right icon-user"></i>Manage Group Members</a></li>
              <li><a style="background-color: #EEE;" href="<?php echo base_url('groups_manage/group_event/'); ?>"><i class="pull-right icon-th-list"></i>Manage Group Events</a></li>
              <li><a href="<?php echo base_url('groups_manage/group_event_result/'); ?>"><i class="pull-right icon-signal"></i>Manage Group Event Results</a></li>
              <li><a href="<?php echo base_url('groups_manage/api_apps/'); ?>"><i class="pull-right icon-fire"></i>API Apps</a></li>
            </ul>
          </div>
        </div>
        <div class="span9">
          <div class="btn-group pull-right">
            <a href="#add_group_event" data-toggle="modal" class="btn">Add Group Event</a>
            <a title="<?php echo 'Can accessed by : @' . @implode(', @', $this->comitte_members); ?>" href="<?php echo base_url('groups_manage'); ?>" class="btn">Manage groups</a>
          </div>
          <h4 class="header">Group events [<?php echo NOW_YEAR; ?>]</h4>
          <?php if (!empty($group_events)) { ?>
            <table class="table table-striped table-bordered">
              <thead>
                <tr>
                  <th width="5%">#</th>
                  <th width="70%">Name</th>
                  <th width="5%">Max. score</th>
                  <th width="5%">Year</th>
                  <th width="10%">Date</th>
                  <th width="5%">Action</th>
                </tr>
              </thead>
              <tbody>
                <?php $count = 1; ?>
                <?php foreach ($group_events as $group_event) { ?>
                  <tr>
                    <td><?php echo $count; ?></td>
                    <td><?php echo $group_event['group_event_name']; ?></td>
                    <td><?php echo $group_event['group_event_max_score']; ?></td>
                    <td><?php echo $group_event['group_event_year']; ?></td>
                    <td><?php echo date('Y-m-d', strtotime($group_event['group_event_date'])); ?></td>
                    <td>
                      <a title="Delete group event" style="text-decoration: none; color: tomato; cursor: pointer;" onclick="return confirm_action('Delete group event ?');" href="<?php echo site_url('groups_manage/group_event_delete/' . $group_event['group_event_id']); ?>"><i class="icon-large icon-trash"></i></a>
                    </td>
                  </tr>
                  <?php $count++; ?>
                <?php } ?>
              </tbody>
            </table>
          <?php } else { ?>
            <div class="alert alert-danger">No group events !</div>
          <?php } ?>
        </div>
      </div>
    </div>
  </div>
</div>

<div id="add_group_event" class="modal hide fade">
  <div class="modal-header">
    <button type="button" data-dismiss="modal" aria-hidden="true" class="close">&times;</button>
    <h3>Add group event [<?php echo NOW_YEAR; ?>]</h3>
  </div>
  <form class="form-horizontal" method="post" action="<?php echo base_url('groups_manage/group_event_add'); ?>">
    <input type="hidden" name="csrf_token" value="<?php echo set_csrf_token(); ?>"/>
    <div class="modal-body">
      <div class="control-group">
        <label class="control-label">Group Event Name</label>
        <div class="controls">
          <input id="group_event_name" name="group_event_name" type="text" placeholder="Group event name (250)" required="required"/>
        </div>
      </div>
      <div class="control-group">
        <label class="control-label">Event Max. Score</label>
        <div class="controls">
          <input id="group_event_max_score" name="group_event_max_score" type="number" min="0" step="1" pattern="\d+" placeholder="Group event maximum score" required="required"/>
        </div>
      </div>
      <div class="control-group">
        <label class="control-label">Group Event Date</label>
        <div class="controls">
          <input id="group_event_date" name="group_event_date" type="text" placeholder="Group event date" required="required"/>&nbsp;<i class="icon-calendar"></i>
        </div>
      </div>
    </div>
    <div class="modal-footer">
      <button data-dismiss="modal" class="btn">Close</button>
      <button type="submit" class="btn btn-primary">Save</button>
    </div>
  </form>
</div>
